package com.neuedu.corejava.ch3;

import java.util.Scanner;

public class LoopPractice {

	public static void main(String[] args) {
		
		//循环可进行多级嵌套，但建议不要超过五级
		/*for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 6; j++) {
				System.out.print("*");// 打印不换行
			}
			System.out.println();// 打印并换行
		}*/
		//作业：  使用*号进行表示，分别打印出三角形，正三角，反三角形，菱形，空心的菱形
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入一个数字：");
		int row = scanner.nextInt();
		
		/*for (int i = 0; i < row; i++) {
			for (int j = 0; j <= i; j++) {
				System.out.print("*");
			}
			System.out.println();
		}*/
		//正三角
		/*for (int i = 0; i <= row; i++) {
			for (int j = 0; j < row-i; j++) {
				System.out.print(" ");
			}
			for (int j = 0; j < 2*i-1; j++) {
				System.out.print("*");
			}
			System.out.println();		
		}*/
		//反三角
		for (int i = row; i > 0; i--) {
			for (int a = row; a > i; a--) {
				System.out.print(" ");
			}
			for (int b = 2 * i-1; b > 0; b--) {
				System.out.print("*");
			}
			System.out.println();
		}
		
		
		//实心菱形
		/*for (int i = 1; i <= row; i++) {
			for (int a = row - i; a >= 0; a--) {
				System.out.print(" ");
			}
			for (int b = 1; b <= 2 * i - 1; b++) {
				System.out.print("*");
			}
			System.out.println();
		}

		for (int i = row; i >= 0; i--) {
			for (int a = row; a > i; a--) {
				System.out.print(" ");
			}
			for (int b = 2 * i; b >= 0; b--) {
				System.out.print("*");
			}
			System.out.println();
		}*/
		//空心菱形
		/*for (int i = 1; i <= row; i++) {
            for (int n = 0; n < row - i; n++) {
                System.out.print(" ");
            }
            for (int j = 0; j < 2 * i - 1; j++) {
                if(j == 0 || j == 2 * i - 2) {
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
        for (int i = row - 1; i > 0; i--) {
            for (int n = 0; n < row - i; n++) {
                System.out.print(" ");
            }
            for (int j = 0; j < 2 * i - 1; j++) {
                if(j == 0 || j == 2 * i - 2) {
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }*/

	}
}
